{extend name="common@create" /}
{block name="formaa"}
	<form action="/kaoshi/{$list.id}" method="PUT" class="form form-horizontal" id="form-member-add">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>组织单位：</label>
			<div class="formControls col-xs-8 col-sm-9 f-l">
				<span class="select-box f-l">
				{php}
					$school = schlist('班级','区级');
				{/php}
				<select class="select" id="zuzhi" name="zuzhi" size="1" required>
					<option value="">--请选择组织单位--</option>
					{volist name="school" id="vo"}
						<option value="{$vo.id}" {eq name="$list.zuzhi" value="$vo.title" }selected{/eq}>{$vo.title}</option>
					{/volist}
				</select>
				</span>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>标题：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$list.title}" placeholder="显示的考试名称" id="title" name="title">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>学期：</label>
			<div class="formControls col-xs-8 col-sm-9 f-l">
				<span class="select-box f-l" style="width:220px;">
				{php}
					$xq = new app\teach\model\Xueqi;
					$xueqi = $xq->where('status',1)->order(['id'=>'desc'])->limit(5)->field('id,title')->select();
				{/php}
				<select class="select" id="xueqi" name="xueqi" size="1" required>
					<option value="">--请选择学期--</option>
					{volist name="xueqi" id="vo"}
						<option value="{$vo.id}" {eq name="$list.xueqi" value="$vo.title" }selected{/eq}>{$vo.title}</option>
					{/volist}
				</select>
				</span>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>分类：</label>
			<div class="formControls col-xs-8 col-sm-9 f-l">
				<span class="select-box f-l" style="width:180px;">
				{php}$category = getCategory(109);{/php}
				<select class="select" id="category" name="category" size="1" required>
					<option value="">--请选择考试分类--</option>
					{volist name="category" id="vo"}
						<option value="{$vo.id}" {eq name="$list.category" value="$vo.title" }selected{/eq}>{$vo.title}</option>
					{/volist}
				</select>
				</span>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>考试时间：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text Wdate" style="max-width:120px" value="{$list.bfdate}" placeholder="开始" id="bfdate" name="bfdate" onclick="WdatePicker({isShowClear:false,readOnly:true})">
				<span class="ml-10">~</span>
				<input type="text" class="input-text Wdate ml-10" style="max-width:120px" value="{$list.enddate}" placeholder="结束" id="enddate" name="enddate" onclick="WdatePicker({isShowClear:false,readOnly:true})">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>参考年级：</label>
			<div class="formControls col-xs-8 col-sm-9">
					<dt>{foreach $njlist=nianjilist() as $key=>$vo } 
						<label class="ml-10">
							<input type="checkbox" value="{$key}" name="nianji[]" id="nianji{$key}" {in name="key" value="$list.nianjiids"}checked{/in} required>
							{$vo}
						</label>{/foreach}
					</dt>
			</div>
		</div>
		<div class="row cl">
			{php}
				$subject = new \app\teach\model\Subject;
				$sjlist = $subject->where('status',1)->where('id','<=',3)->field('id,title')->order(['paixu'])->select();
			{/php}
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>参考学科：</label>
			<div class="formControls col-xs-8 col-sm-9">
					<dt>{foreach $sjlist as $key=>$vo } 
							{present name="$list['manfenedit'][$vo.id]"}
							<dd>
							<label class="ml-10">
								<input class=" mt-10" type="checkbox" value="{$vo.id}" name="subject[]" id="subject{$vo.id}" onclick="xueke(this)" checked="true" required>
								{$vo.title}
							</label>
							<input type="text" name="manfen[]" value="{$list['manfenedit'][$vo.id]}" id="manfen[]" class="input-text ml-15 mt-5" placeholder="满分默认100" style="max-width: 250px" onchange="manfenbut(this)" value="98">
							</dd>
							{else /}
							<dd>
							<label class="ml-10">
								<input class=" mt-10" type="checkbox" value="{$vo.id}" name="subject[]" id="subject{$vo.id}" onclick="xueke(this)">
								{$vo.title}
							</label>
							<input type="text" name="manfen[]" value="" id="manfen[]" class="input-text ml-15 mt-5" placeholder="满分默认100" style="max-width: 250px" onchange="manfenbut(this)">
							</dd>
							{/present}

						
					{/foreach}
					</dt>
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
{/block}
{block name="yanzheng"}
<script type="text/javascript">

	// 设置表单验证规则
	var myrules = {
			title:{
				required:true,
				rangelength:[2,25]
			},
			bfdate:{
				required:true,
				dateISO:true
			},
			enddate:{
				required:true,
				dateISO:true
			},
		};

	// 设置表单提交方式
	var mytype = 'PUT';

	// 选择学科添加满分文本框
	function xueke(obj)
	{
		// 当选中复选框，则添加满分，否则删除满分
		if($(obj).prop('checked') == true)
		{
			$(obj).parents('dd').find('input[type=text]').val(100);
		}else{
			$(obj).parents('dd').find('input[type=text]').val('');
		}
	}

	// 添满分后自动选复选框
	function manfenbut(obj)
	{
		// 当文本框输入数字时，则选中复选框，否则不选中
		if( $(obj).val() > 0 )
		{
			$(obj).parents('dd').find('input[type=checkbox]').attr('checked',true);
		}else{
			$(obj).parents('dd').find('input[type=checkbox]').attr('checked',false);
		}
	}
</script>
{/block}